



#ifndef _PDF_ENCODING_H_
#define _PDF_ENCODING_H_

#include <wx/string.h>

#include "wx/pdfdocdef.h"
#include "wx/pdfarraytypes.h"
#include "wx/pdffontdata.h"

/// Class representing a font encoding
class WXDLLIMPEXP_PDFDOC wxPdfEncoding
{
public:
  /// Default constructor
  wxPdfEncoding();

  /// Destructor
  virtual ~wxPdfEncoding();

  /// Copy constructor
  wxPdfEncoding(const wxPdfEncoding& encoding);

  /// Assignment operator
  wxPdfEncoding& operator=(const wxPdfEncoding& encoding);

  /// Check whether the encoding is valid
  
  bool IsOk() const;

  /// Set the encoding
  
  bool SetEncoding(const wxString& encoding);

  /// Get the name of the encoding
  
  wxString GetEncodingName() const;

  /// Get the name of the base encoding
  
  wxString GetBaseEncodingName() const;

  /// Get the differences between the encoding and the associated base encoding
  
  wxString GetDifferences() const;

  /// Get the character map of the encoding
  
  wxPdfArrayUint32 GetCMap() const;

    void InitializeEncodingMap();

  /// Get the encoding map
  
  const wxPdfChar2GlyphMap* GetEncodingMap() const;

  /// Get the list of glyph names supported by the encoding
  
  wxArrayString GetGlyphNames() const;

  /// Convert a glyph name to a unicode character
  
  static bool GlyphName2Unicode(const wxString& glyphName, wxUint32& unicode);

  /// Convert a unicode character to a glyph name
  
  static bool Unicode2GlyphName(wxUint32 unicode, wxString& glyphName);

  /// Get a list of known encodings
  
  static wxArrayString GetKnownEncodings();

protected:
    void CreateEncodingConvMap();

private:
  wxString            m_encoding;         ///< name of the encoding
  wxString            m_baseEncoding;     ///< name of the base encoding
  wxPdfArrayUint32    m_cmap;             ///< character map of the encoding
  wxPdfArrayUint32    m_cmapBase;         ///< character map of the base encoding
  wxArrayString       m_glyphNames;       ///< array of glyph names in the encoding
  bool                m_specific;         ///< flag whether the encoding is specific
  int                 m_firstChar;        ///< number of the first valid character
  int                 m_lastChar;         ///< number of the last valid character
  wxPdfChar2GlyphMap* m_encodingMap;      ///< Encoding conversion map
};

/// Class representing a font encoding checker
class WXDLLIMPEXP_PDFDOC wxPdfEncodingChecker
{
public:
  /// Default constructor
  wxPdfEncodingChecker();

  /// Destructor
  virtual ~wxPdfEncodingChecker();

  /// Get the name of the encoding used for checking
  
  wxString GetEncodingName() const;

  /// Check whether a given Unicode character is included in the encoding
  
  virtual bool IsIncluded(wxUint32 unicode) const = 0;

protected:
  wxString         m_encoding;         ///< name of the encoding
};

#endif
